package com.gobi;

import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;

/**
 * Created by YingYou on 2016/8/7.
 */
@SpringBootApplication
public class SpringbootTestApplication extends SpringBootServletInitializer {

    /**
     * 使用外置tomcat部署
     * 要使用外部容器部署的话，就不能依赖于Application的main函数了，而是要以类似于web.xml文件配置的方式来启动Spring应用上下文。
     * Servlet3.0 可以用ServletContainerInitializer代替web.xml
     * 此时我们需要在启动类中继承SpringBootServletInitializer并实现configure方法：
     */
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringbootTestApplication.class);
    }

    public static void main(String[] args){
        SpringApplication springApplication = new SpringApplication(SpringbootTestApplication.class);
        springApplication.setBannerMode(Banner.Mode.OFF);
        springApplication.run(args);
    }
}
